<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>js函数节流</title>
</head>
<body>
<script type="text/javascript">
    n=0;
    function resizehandler(){
        console.log(new Date().getTime());
        console.log(++n);
    }

    function throttle(method,context){
        clearTimeout(method.tId);
        method.tId=setTimeout(function(){
            method.call(context);
        },100);
    }

    window.onresize=function(){
        throttle(resizehandler,window);
    };
</script>
</body>
</html>